//
// Created by ct on 2021/9/27.
//

#include <stdlib.h>
#include "stack.h"

static char * world = "world";

void hello(){
    printf("%s ",world);
}


// --------------------- stack.h ---------------------
#define STACK_SIZE 100
PRIVATE int contents[STACK_SIZE];
PRIVATE int top = 0;
// terminate

PRIVATE void terminate(const char * message){
    printf("%s \n",message);
    exit(EXIT_FAILURE);
}

PUBLIC void make_empty(void){
    top = 0;
}

PUBLIC bool is_empty(){
 /*   if(top > 0 ){
        return false;
    }
    return true;*/
    return top ==0;
}

PUBLIC bool is_full(void ) {
    return top == STACK_SIZE;
}

PUBLIC void push(int i){
    if (is_full())
        terminate("is full");

    contents[top++] = i;
}

PUBLIC int pop(){
    if (is_empty())
        terminate("is empty");
    return contents[--top];
}



